a = input().split()
itog = ''
dopust = ['one','two','three','four','five','six','seven','eight','nine','zero']
znach = {'one':1,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':9,'zero':0}
for i in a:
    if not(i in dopust):
        print('Wrong input!')
        break
    itog += str(znach[i])
else:
    itog = int(itog)
    for j in range(itog,0,-1):
        if j == 1:
            res = 1
            break
        for i in range(2,j):
            if j % i == 0:
                break
        else:
            res = j
            break

    
    for j in range(itog,itog+itog-res):
        if j == 1:
            res = 1
            break
        for i in range(2,j):
            if j % i == 0:
                break
        else:
            res = j
            break
    
    print(res)
